import request from './request'
export default async function (good) {
  let CartInfo={}
  let count = ""
  let all = ""
  let token = wx.getStorageSync('userInfo').token
  let res = await request("api/shoppingCarList", {
    token
  })
  if (res.code === 2000) {
    count = res.data.count
    all = await request("api/shoppingCarList", {
      token,
      size: count
    })
  }
  let cartList = all.data.data
  for (let item of cartList) {
    if (item.good_id == good.good_id && item.sku == good.sku) {
      CartInfo.shopping_car_id = item.shopping_car_id
      CartInfo.num=item.num
      CartInfo.money=item.money
      break
    }
  }
  return CartInfo
}
export const getCount=async function(){
  let count=""
  let token = wx.getStorageSync('userInfo').token
  let res = await request("api/shoppingCarList", {
    token
  })
  if(res.code===2000){
    count = res.data.count
  }
  return count
}